package com.gemalto.Kryptik.Gui;

import bsh.util.JConsole;
import bsh.Interpreter;
import bsh.*;
import javax.swing.JPanel;
import javax.swing.border.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.gemalto.Kryptik.*;


public class ConsoleTab extends JPanel {

	private static Interpreter interpreter;


	public ConsoleTab(String title){
		//super(title);
/*
		addWindowListener(new WindowAdapter() {
		        public void windowClosing(WindowEvent e) {setVisible(false);}
		});

*/
		setLayout(new BorderLayout());	 	
		
	   	JConsole console= new JConsole();
		interpreter = Beanshell.newConsoleInterpreter(console); 
		Thread thread = new Thread( interpreter );
		thread.start();

		//getContentPane().
		add(console, BorderLayout.CENTER);

		//pack();
		//setBounds(100,100,400,200);
	  }




	public void setVariable(String name, Object obj){
	try
	{interpreter.set(name,obj);
	}
	catch (EvalError e)
	{Messenger.error(e.getMessage());
	}
	};
/*
	public void show(){
		this.setVisible(true);
	}


	public void hide(){
		this.setVisible(false);
	}

*/
}
